package com.javabase.lambda;

import lombok.extern.slf4j.Slf4j;

import java.util.Comparator;
import java.util.LinkedList;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;

/**
 * @author huilin_rong
 * @date 2021/01/18
 */
@Slf4j
public class TestNewFeature {

    public static void main(String[] args) {
        List<Score> list = new LinkedList<>();
        list.add(new Score("lhp", 78));
        list.add(new Score("rhl", 65));
        list.add(new Score("ha", 87));
        list.add(new Score("lp", 77));

        List<Score> excellenceList = list.stream().filter(
                score -> (score.getScore() > 80)
        ).collect(Collectors.toList());
        log.info("filter: {}", excellenceList);

        List<Score> sortedList = list.stream().sorted(Comparator.comparingInt(Score::getScore))
                .collect(Collectors.toList());
        log.info("sorted: {}", sortedList);

        Address address = new Address();
        Country country = new Country();
        country.setOldCode(true);
        address.setCountry(country);
        User user = new User();
        user.setId(1);
        user.setName("hello");
        user.setAddress(address);

        User testUser = null;
        Optional<User> optionalUser = Optional.ofNullable(user);

    }

}
